/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import remoteEntity.Log;

/**
 *
 * @author viktor
 */
@Stateless
public class LogFacade extends AbstractFacade<Log> {
    @PersistenceContext(unitName = "filecityeePU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public LogFacade() {
        super(Log.class);
    }
    
    @Override
    public List findAll() {
        return em.createNamedQuery("Log.findAll").getResultList();
    }

    public void log(String page, String msg, String level) {
        Log log = new Log();
        log.setDate(new Date());
        log.setLevel(level);
        log.setMessage(msg);
        log.setPage(page);
        em.persist(log);
    }
    
}
